import * as constants from './constants';
import {fromJS} from 'immutable';
import axios from 'axios';

const changeList=(data)=>({
  type:constants.CHANGE_LIST,
  data:fromJS(data),
  totalPage:Math.ceil(data.length/10)
})

export const searchFocus=()=>({
 type:constants.SEARCH_FOCUS
})

export const searchBlur=()=>({
  type:constants.SEARCH_BLUR
})

export const MouseEnte=()=>({
  type:constants.MOUSE_ENTER
})

export const MouseLeave=()=>({
  type:constants.MOUSE_LEAVE
})

export const changePageList=(page)=>({
  type:constants.CHANGE_PAGE,
	page
})





export const getList=()=>{
  return (dispatch)=>{
    axios.get('/api/headerList.json').then((res)=>{
      const data=res.data.data
      dispatch(changeList(data))
    })
    .catch((err)=>{
      console.log('err')
    })
  }
}